using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter13
{
	/// <summary>
	/// Example08: Escape Speed of a Rocket
	/// Calculate the escape speed from the Earth 
	/// for 5000-kg spacecraft, and determine the kinetic 
	/// enery it must have at the Earth's surface in order 
	/// to move infinitely far away from the Earth.
	/// v_{esc} = 1.12 \times 10^4 m/s
	/// K = 3.14 \times 10^{11} J
	/// </summary>
	public class Example08
	{
		public Example08()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass m = new L.Mass();
			m.kg = 5000.0;
			L.PotentialEnergy Ui = new L.PotentialEnergy();
			Ui.J = -m.kg*L.Constant.AccelerationOfGravity
				*L.Earth.Radius;
			L.PotentialEnergy Uf = new L.PotentialEnergy();
			Uf.J = 0.0;
			L.KineticEnergy Ki = new L.KineticEnergy();
			Ki.VariableQ = true;
			L.KineticEnergy Kf = new L.KineticEnergy();
			Kf.J = 0.0;
			L.FundamentalLaw.EnergyConservation(Ki,Ui,Kf,Uf);
			result += Convert.ToString(Ki.J)+"\r\n";
			L.Velocity vesc = new L.Velocity(m,Ki);
			result += Convert.ToString(vesc.mPERs)+"\r\n";
		}
	}
}
